<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<head>
    <meta charset="utf-8" />
    <title>祈贝健康--后台管理系统</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />

    <!-- ================== BEGIN BASE CSS STYLE ================== -->
    <link href="./Public/Admin/assets/plugins/jquery-ui/themes/base/minified/jquery-ui.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/css/animate.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/css/style.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/css/style-responsive.min.css" rel="stylesheet" />
    <link href="./Public/Admin/assets/css/theme/default.css" rel="stylesheet" id="theme" />
    <!-- ================== END BASE CSS STYLE ================== -->

    <!-- ================== BEGIN PAGE LEVEL STYLE ================== -->
    <link href="./Public/Admin/assets/plugins/DataTables/css/data-table.css" rel="stylesheet" />
    <!-- ================== END PAGE LEVEL STYLE ================== -->

    <!-- ================== BEGIN BASE JS ================== -->
    <script src="./Public/Admin/assets/plugins/pace/pace.min.js"></script>
    <!-- ================== END BASE JS ================== -->
</head>
<body>
<php> include './Public/Admin/header.html'; </php>



<!-- begin #content -->
<div id="content" class="content">
    <!-- begin breadcrumb -->
    <ol class="breadcrumb pull-right">
        <li><a href="javascript:;">首页</a></li>
        <li><a href="javascript:;">酒店管理</a></li>
        <li class="active">修改酒店信息</li>

    </ol>
    <!-- end breadcrumb -->
    <!-- begin page-header -->
    <h1 class="page-header">酒店管理 <small>修改酒店信息</small></h1>
    <!-- end page-header -->

    <!-- begin row -->
    <div class="row">
        <!-- begin col-12 -->
        <div class="col-md-12">
            <!-- begin panel -->
            <div class="panel panel-inverse">
                <div class="panel-heading">
                    <div class="panel-heading-btn">
                        <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-default" data-click="panel-expand"><i class="fa fa-expand"></i></a>
                        <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-success" data-click="panel-reload"><i class="fa fa-repeat"></i></a>
                        <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-warning" data-click="panel-collapse"><i class="fa fa-minus"></i></a>
                        <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-danger" data-click="panel-remove"><i class="fa fa-times"></i></a>
                    </div>
                    <h4 class="panel-title">修改酒店信息</h4>
                </div>
                <div class="panel-body">
                    <div class="table-responsive">


                        <!--表单-->

                        <div class='col-md-10'>
                            <form class='form-horizontal' role='form'  method="post" action="index.php?m=Admin&c=Hotel&a=lists&type=2" enctype="multipart/form-data">
                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>酒店中文名称：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="cn_name" id='cn_name' placeholder='请输入酒店中文名称' value="">
                                    </div>
                                </div>
                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>酒店英文名称：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="en_name" id='en_name' placeholder='请输入酒店英文名称' value="">
                                    </div>
                                </div>
                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>所属国家：</label>
                                    <div class='col-md-4'>
                                        <select onchange="loadCity()" class='form-control' name="country" id="countryid">


                                        </select>
                                    </div>
                                </div>
                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>所属城市：</label>
                                    <div class='col-md-4'>
                                        <select  onchange="loadHospital()" class='form-control' name="city" id="cityId">


                                        </select>
                                    </div>
                                </div>
                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>附近医院名称：</label>
                                    <div class='col-md-4'>
                                        <select class='form-control' name="hid" id="hospitalId">


                                        </select>
                                    </div>
                                </div>

                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>地址：</label>
                                    <div class='col-md-4'>
                                        <textarea class="form-control" rows='3' name="addr" id="addr"  placeholder="请输入地址"></textarea>
                                    </div>
                                </div>
                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>酒店介绍：</label>
                                    <div class='col-md-4'>
                                        <textarea class="form-control" rows='3' name="abstract" id="abstract"  placeholder="请输入中文介绍"></textarea>
                                    </div>
                                </div>
                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>距离：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="distance" id='distance' placeholder='请输入地址' value="">
                                    </div>
                                </div>
                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>星级：</label>
                                    <div class='col-md-4'>
                                        <textarea class="form-control" rows='3' name="level" id="level"  placeholder="1-5星"></textarea>
                                    </div>
                                </div>
                                <div class='form-group'>
                                    <label for='inputtext' class='col-md-2 control-label'>网址：</label>
                                    <div class='col-md-4'>
                                        <input type='text' class='form-control input-lg' name="link" id='link' placeholder='请输入网址' value="">
                                    </div>
                                </div>
                                <div class='form-group' id="addInput">
                                    <label for='inputtext' class='col-md-2 control-label'>酒店图片</label>
                                    <div class='col-md-4'>
                                        &nbsp;&nbsp;&nbsp;&nbsp;<a id="but" class="btn btn-primary">加</a>
                                    </div>

                                </div>
                                <div class='form-group' id="addHotel">
                                    <label for='inputtext' class='col-md-2 control-label'>photo</label>

                                </div>


                                <div class='form-group'>
                                    <div class='col-md-3 col-md-offset-2'>
                                        <button  class='btn btn-success btn-radius'>提交</button>
                                    </div>
                                </div>
                            </form>
                        </div>


                    </div>
                </div>
            </div>
            <!-- end panel -->
        </div>
        <!-- end col-12 -->
    </div>
    <!-- end row -->
</div>
<!-- end #content -->


<!-- begin scroll to top btn -->
<a href="javascript:;" class="btn btn-icon btn-circle btn-success btn-scroll-to-top fade" data-click="scroll-top"><i class="fa fa-angle-up"></i></a>
<!-- end scroll to top btn -->
<?php include './header.html'; ?>
<!-- end page container -->

<!-- ================== BEGIN BASE JS ================== -->
<script src="./Public/Admin/assets/plugins/jquery/jquery-1.9.1.min.js"></script>
<script src="./Public/Admin/assets/plugins/jquery/jquery-migrate-1.1.0.min.js"></script>
<script src="./Public/Admin/assets/plugins/jquery-ui/ui/minified/jquery-ui.min.js"></script>
<script src="./Public/Admin/assets/plugins/bootstrap/js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
<script src="./Public/Admin/assets/crossbrowserjs/html5shiv.js"></script>
<script src="./Public/Admin/assets/crossbrowserjs/respond.min.js"></script>
<script src="./Public/Admin/assets/crossbrowserjs/excanvas.min.js"></script>
<![endif]-->
<script src="./Public/Admin/assets/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<!-- ================== END BASE JS ================== -->

<!-- ================== BEGIN PAGE LEVEL JS ================== -->
<script src="./Public/Admin/assets/plugins/DataTables/js/jquery.dataTables.js"></script>
<script src="./Public/Admin/assets/plugins/DataTables/js/dataTables.colVis.js"></script>
<script src="./Public/Admin/assets/js/apps.min.js"></script>
<!-- ================== END PAGE LEVEL JS ================== -->
<script>
    $(document).ready(function() {
        App.init();

        loadc();
    });
    var dataNum=-1;//增加的条数



    function loadc(){
        var hospitalid;
        var countryName;

        $.getJSON("index.php?m=Admin&c=Hotel&a=update_list",function(result){
            if(result!=0){
                hospitalid=result.hid;
                countryName=result.country;
                $('#link').val(result.link);
                $('#distance').val(result.distance);
                $('#cn_name').val(result.cn_name);
                $('#en_name').val(result.en_name);
                $('#level').val(result.level);
                $('#abstract').val(result.abstract);
                $('#addr').val(result.addr);
            }
        });

     //============================= 获取图片地址===========================================
        $.getJSON("index.php?m=Admin&c=Hotel&a=update_imgs&type=1",function(result){
            hotelId=result.id;
            if(result!=0){
                var num= result.num;//统计拼接图片的总数量&&&&&//用于计数，用于判断增加图片上传表单时需要再上传多少张图片。
                dataNum=num-1;
                for(var i=0; i<=num-1; i++){
                    var addhtml= '<div  class="form-group" id="imgs'+i+'">';
                        addhtml+="<label for='inputtext' class='col-md-2 control-label'></label>";
                        addhtml+= '<div class="col-xs-6 col-md-2"><a href="#" class="thumbnail"><img src="./image_hotel/'+result[i].imgs +'"></a>';
                        addhtml+='<div class="col-md-5">&nbsp;&nbsp;<div class="col-md-8"><a class="btn btn-success" id="del'+i+'" onclick="del('+"'"+result[i].imgs+"',"+i+')" >删除</a></div></div></div>';
                $("#addHotel").after(addhtml);

              }
            }
        });
    /*=======================获取国家信息==========================*/
        $.getJSON("index.php?m=Admin&c=Hotel&a=get_country_list",function(result) {
            var html = '<option value="-1">--请选择--</option>';
            if (result != null) {
                $.each(result, function (key, val) {
                    if (countryName == val.countryname_cn) {
                        html += '<option value="' + val.countryid + '" selected>' + val.countryname_cn + '</option>';
                    } else {
                        html += '<option value="' + val.countryid + '">' +val.countryname_cn + '</option>';
                    }
                });
            }
            $("#countryid").html(html);
            //=============================在数据库里取出数据，用于显示修改前的地区
            $.getJSON("index.php?m=Admin&c=Hotel&a=get_city_one&hid="+hospitalid,function(result) {
                var html = '';
                if (result != null) {
                            html += '<option value="' + result.id + '">' + result.name + '</option>';
                }
                $("#cityId").html(html);
            });

            ///===============================获得医院=========================================================

            $.getJSON("index.php?m=Admin&c=Hotel&a=get_hospital_one&hid="+hospitalid,function(result) {
                var html = '';
                if (result != null) {
                    html += '<option value="' + result.id + '" selected>' +result.name+ '</option>';
                }
                $("#hospitalId").html(html);
            });
        });

        //===================================增加图片上传表单=====================================
        $("#but").click(function(){
            if(dataNum<4){
                dataNum++;
                var newRow='<div  class="col-md-4 col-md-offset-2"><input type="file" name="imgs[]" id="inputImage'+dataNum+'"/></div>';
                newRow+='<div class="col-md-2"><a class="btn btn-success" id="inputDel'+dataNum+'" onclick="inputDel('+dataNum+')" >删除</a></div>';
                $("#addInput").after(newRow);
            }
        });

    }

//========================删除修改显示的图片===========================
    function del(obj,obj1){
        $.getJSON("index.php?m=Admin&c=Hotel&a=update_imgs&type=2&imgNum="+obj,function(result){
            dataNum--;
            if(result!=0){
               $("#imgs"+obj1).remove();
            }
        });
    }
    //============================删除添加表单的==================================
    function inputDel(obj){
        dataNum--;
        $("#inputImage"+obj).remove();
        $("#inputDel"+obj).remove();
    }
    /*=======================获得地区信息==========================*/
    function loadCity(){
            var a=$("#countryid").find("option:selected").val();
            $.getJSON("index.php?m=Admin&c=Hotel&a=get_city_list&cid="+a,function(result){
                var html = '<option value="-1">--请选择--</option>';
              if(result!=null){
                   $.each(result,function(key,val){
                      html += '<option value="' + val.id + '">' + val.name + '</option>';
                });
              }
               $("#cityId").html(html);
            });
    }
    function loadHospital(){
        var a= $("#cityId").find("option:selected").val();
        $.getJSON("index.php?m=Admin&c=Hotel&a=get_hospital_list&zid="+a,function(result){
            var html = '<option value="-1">--请选择--</option>';
            if(result!=null){
                $.each(result,function(key,val){
                    html += '<option value="' + val.id + '">' + val.name + '</option>';
                });
            }
            $("#hospitalId").html(html);
        });
   }

</script>
</body>
</html>

